Type Classes in Functional Logic Programming Author’s version for E-Prints Complutense

نویسنده

  • Enrique Martin-Martin
چکیده

Type classes provide a clean, modular and elegant way of writing overloaded functions. Functional logic programming languages (FLP in short) like Toy or Curry have adopted the Damas-Milner type system, so it seems natural to adopt also type classes in FLP. However, type classes has been barely introduced in FLP. A reason for this lack of success is that the usual translation of type classes using dictionaries presents some problems in FLP like the absence of expected answers due to a bad interaction of dictionaries with the call-time choice semantics for non-determinism adopted in FLP systems. In this paper we present a type-passing translation of type classes based on type-indexed functions and type witnesses that is well-typed with respect to a new liberal type system recently proposed for FLP. We argue the suitability of this translation for FLP because it improves the dictionary-based one in three aspects. First, it obtains programs which run as fast or faster—with an speedup from 1.05 to 2.30 in our experiments. Second, it solves the mentioned problem of missing answers. Finally, the proposed translation generates shorter and simpler programs.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

On Elementary Linear Logic and polynomial time

Linear logic (LL) [Gir87] has been used in implicit computational complexity to characterize various complexity classes within the proofs-as-programs approach. This can then be the basis of type systems to guarantee complexity properties on lambda-calculus. As duplication is controlled in LL by the connective ! the key idea of this line of work is to consider variants of this system with a weak...

متن کامل

Adding Type Classes to Functional-Logic Languages

The paper discusses the advantages of introducing type classes into functional-logic languages. Type classes are a powerful type system included in the functional language Haskell that allow to model some of the object oriented programming features. A number of problems arise when type classes are combined with the functional and logic characteristics of the language, and we sketch some solutio...

متن کامل

Some fixed point theorems for weakly subsequentially continuous and compatible of type (E) mappings with an application

In this paper, we will establish some xed point results for two pairs of self mappings satisfying generalized contractive condition by using a new concept as weak subsequential continuity with compatibility of type (E) in metric spaces, as an application the existence of unique common solution for a system of functional equations arising in system programming is proved.

متن کامل

Lambda Calculus with Types

This handbook with exercises reveals in formalisms, hitherto mainly used for hardware and software design and verification, unexpected mathematical beauty. The lambda calculus forms a prototype universal programming language, which in its untyped version is related to Lisp, and was treated in the first author’s classic The Lambda Calculus (1984). The formalism has since been extended with types...

متن کامل

Contextual equivalence for inductive definitions with binders in higher order typed functional programming

Correct handling of names and binders is an important issue in meta-programming. This paper presents an embedding of constraint logic programming into the αML functional programming language, which provides a provably correct means of implementing proof search computations over inductive definitions involving names and binders modulo α-equivalence. We show that the execution of proof search in ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2011